package com.xp.record25.bio;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.Charset;

public class OldBioServer {

    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket();
        serverSocket.bind(new InetSocketAddress("localhost", 8888));

        while (true) {
            System.out.println("等待链接。。。");
            Socket sc = serverSocket.accept();
            System.out.println("已连接。。。");
            InputStream is = sc.getInputStream();
            byte[] bytes = new byte[1024];
            is.read(bytes);
            String s = new String(bytes, 0, bytes.length, Charset.defaultCharset());
            System.out.println("接收到客户端消息" +s );
        }

    }
}
